import Taro, {Component} from '@tarojs/taro'
import {View, Text} from '@tarojs/components'
import './activity.scss'

export default class Activity extends Component {
    constructor() {
        super(...arguments);
        this.state = {
            activity: [{
                type: 'cut',
                info: [{total: "40", cut: "10"}, {total: "58", cut: "15"}, {total: "80", cut: "30"},]
            }]
        }
    }
    getTextType(type){
        switch (type) {
            case 'cut':
                return "减";
                break;
            default:
                break;
        }
    }
    getLine(arr){
        return arr.map((item,index)=>`满${item.total}减${item.cut}`).join(';')
    }
    render() {
        const {activity:[firstItem]} = this.state;
        return (
            <View className='activity'>
                <View className='activity-left'>
                    {/*<Image className='activity-left-img' src={require('../../assets/img/reduce.png')}></Image>*/}
                    <Text className='activity-left-type'>{this.getTextType(firstItem.type)}</Text>
                    <Text className='activity-left-text'>{this.getLine(firstItem.info)}</Text>
                </View>
                <Text className='activity-sum'>{this.state.activity.length}个活动</Text>
            </View>
        )
    }
}
